package com.xysoft.framework.mvc;

import org.springframework.aop.framework.ProxyFactoryBean;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.InitializingBean;

import com.xysoft.framework.alias.AliasRegistry;

public class ControllerProxyFactoryBean extends ProxyFactoryBean implements BeanNameAware, InitializingBean {

	private static final long serialVersionUID = 4145335465286997919L;
	
	private String alias;
	private String entityName;
	
	private String controllerName;
	private AliasRegistry aliasRegistry;
	
	public void setAlias(String alias) {
		this.alias = alias;
	}

	public void setEntityName(String entityName) {
		this.entityName = entityName;
	}

	public void setAliasRegistry(AliasRegistry aliasRegistry) {
		this.aliasRegistry = aliasRegistry;
	}

	@Override
	public void afterPropertiesSet() throws Exception {
		this.aliasRegistry.register(alias, entityName, controllerName);
	}

	@Override
	public void setBeanName(String name) {
		this.controllerName = name;
	}

}
